home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / WINTOOLS.CMD < prev    next >
OS/2 REXX Batch file  |  1993-11-03  |  3KB  |  111 lines

  1. EXTPROC CEnvi
  2. // WinTools.cmd - CEnvi demonstration program to show the capabilities
  3. //                of the WinTools.lib functions.
  4.  
  5. #include <Pmdll.lib>
  6. #include <WinTools.lib>
  7.  
  8. printf("Moving CEnvi text window to middle of the screen...");
  9.  
  10. // Save current dimensions of cenvi window
  11. GetWindowRect(Info().WinHandle,SavePosition);
  12. SaveMaximized = IsMaximized(Info().WinHandle);
  13.  
  14. // Try to change size of CEnvi window so that it is 1/4 screen height and full width
  15. // PM might make it LESS than this size
  16. GetScreenSize(ScreenWidth,ScreenHeight);
  17. SetSize(Info().WinHandle,ScreenWidth,ScreenHeight / 4);
  18.  
  19. // Center CEnvi window in the screen
  20. GetSize(Info().WinHandle,width,height);
  21. printf("Set to %d %d\n",(ScreenWidth - width) / 2,(ScreenHeight - height) / 2);
  22. SetPosition(Info().WinHandle,(ScreenWidth - width) / 2,(ScreenHeight - height) / 2);
  23.  
  24. // Add lots of lines to make sure we can read the new lines on the screen
  25. for ( i = ScreenSize().row; i; i-- )
  26.    printf("\n");
  27.  
  28. // Start up E.EXE
  29. printf("\nStarting E.EXE...");
  30. if ( IsWindow("e.exe") ) {
  31.    printf("\n\n\aERROR: E.EXE must NOT be running to run this test.");
  32.    printf("\nPress any key to quit...");
  33.    getch();
  34.    exit(1);
  35. }
  36. system("Start /F /N E.EXE");
  37. // Wait for e.exe to exist
  38. while ( !IsWindow("e.exe") )
  39.    suspend(100);
  40.  
  41. // Restore this CEnvi screen as the active one
  42. SetActiveWindow(Info().WinHandle);
  43.  
  44. printf("\nPress any key to move E.EXE to upper-left corner...");
  45. getch();
  46. GetSize("e.exe",width,height);
  47. SetPosition("e.exe",0,ScreenHeight - height);
  48.  
  49. printf("\nPress any key to move E.EXE to bottom-right corner...");
  50. getch();
  51. SetPosition("e.exe",ScreenWidth - width,0);
  52.  
  53. printf("\nPress any key to fit E.EXE in top center...");
  54. getch();
  55. // make 1/2 width of screen height and width, and center at top
  56. SetSize("e.exe",ScreenWidth / 2,ScreenHeight / 2);
  57. SetPosition("e.exe",ScreenWidth / 4,ScreenHeight / 2);
  58.  
  59.  
  60. printf("\nPress any key to hide E.EXE...");
  61. getch();
  62. ShowWindow("e.exe",SW_HIDE);
  63.  
  64. printf("\nPress any key to show E.EXE...");
  65. getch();
  66. ShowWindow("e.exe",SW_SHOWNOACTIVATE);
  67.  
  68. printf("\nPress any key to minimize E.EXE...");
  69. getch();
  70. ShowWindow("e.exe",SW_MINIMIZE);
  71.  
  72. printf("\nPress any key to maximize E.EXE...");
  73. getch();
  74. ShowWindow("e.exe",SW_SHOWMAXNOACTIVE);
  75.  
  76. printf("\nPress any key to restore E.EXE...");
  77. getch();
  78. ShowWindow("e.exe",SW_RESTORENOACTIVE);
  79.  
  80. printf("\nDemo done, but E.EXE needs a new title.");
  81. printf("\nTerminate E.EXE, or press key here to exit....");
  82.  
  83. // Make e.exe the active window
  84. SetActiveWindow("e.exe");
  85.  
  86. // Will change the title, so save the window handle here
  87. EHandle = GetWindowHandle("e.exe");
  88.  
  89. // Finally, as long as e.exe exists, rotate the advertisement
  90. NewTitle = "  I like CEnvi.    CEnvi is swell!    Thank you, Nombas.  ";
  91. TitleLen = strlen(NewTitle);
  92. while( IsWindow(EHandle)  &&  !kbhit() ) {
  93.    // set to new title
  94.    SetWindowTitle(EHandle,NewTitle);
  95.    // rotate title one character left
  96.    NewLastChar = NewTitle[0];
  97.    strcpy(NewTitle,NewTitle + 1);
  98.    NewTitle[TitleLen-1] = NewLastChar;
  99.    suspend(100);
  100. }
  101.  
  102. // Restore dimensions of cenvi window
  103. printf("\nbye bye");
  104. if ( SaveMaximized )
  105.    ShowWindow(Info().WinHandle,SW_SHOWMAXNOACTIVE);
  106. SetWindowRect(Info().WinHandle,SavePosition);
  107.  
  108. // If window is still running then close it
  109. CloseWindow(EHandle);
  110.  
  111.